/*
 * Copyright (c) 2013-2015 Charkey. All rights reserved.
 *
 * This software is the confidential and proprietary information of Charkey.
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the agreements you entered into with Charkey.
 *
 * Charkey MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 *
 * Charkey SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
 * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package cn.simastudio.talos.core.controller.api;

import cn.simastudio.talos.common.constants.ApiStatusCode;
import cn.simastudio.talos.common.model.JsonResult;
import cn.simastudio.talos.core.service.base.AddressCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Usage: 省市县行政区划代码API
 *
 * @author Charkey
 * @date 2015/6/29 17:10
 */
@RestController
@RequestMapping("/api/address/code")
public class AddressCodeApiController {

    @Autowired
    private AddressCodeService addressCodeService;

    @RequestMapping(value = "/{addressCode}")
    public JsonResult getAddressByCodes(@PathVariable("addressCode") Integer addressCode) {
        JsonResult result = new JsonResult();
        result.setCode(ApiStatusCode.OK);
        result.setData(addressCodeService.getAddressByCode(addressCode));
        return result;
    }
}
